package edu.buaa.act.travel.m.tpdl.moveaction;

import org.json.JSONException;
import org.json.JSONObject;


public class BusAction extends MoveAction {
	public static final String TYPE = "bus";
	String busNumber;

	public String getBusNumber() {
		return busNumber;
	}

	public void setBusNumber(String busNumber) {
		this.busNumber = busNumber;
	}
	
	@Override
	protected JSONObject toJSONObject(){
		JSONObject o = super.toJSONObject();
		try {
			o.put("busNumber", busNumber);
			o.put("type", TYPE);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return o;
	}
	
	@Override
	public void fromJSON(JSONObject j) throws JSONException{
		super.fromJSON(j);
		this.setBusNumber(j.getString("busNumber"));
	}
	
	@Override
	public String toString(){
		return "坐"+busNumber+"公交车"+" 从 "+startPlace+ " 到 "+endPlace;
	}
}
